package com.atzhou.service;

import com.atzhou.dao.EmployeesMapper;
import com.atzhou.entity.Employees;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class EmployeeService {
    @Autowired
    private EmployeesMapper employeesMapper;

    public List<Employees> getAll(){

        return employeesMapper.selAll();
    }

    public void delById(Integer id){
        int i = employeesMapper.deleteByPrimaryKey(id);
        System.out.println(i);
    }

    public Employees putEmployeeById(Integer id){
        Employees employees = employeesMapper.selectByPrimaryKey(id);

        return employees;
    }

    public Employees putEmpBydidAndDepartment(Integer id){
        Employees employees = employeesMapper.selEmployeeAndDepartmentById(id);

        return employees;
    }

    public void upEmpById(Employees employees){
        int i = employeesMapper.upEmpById(employees);
        System.out.println(i);
    }

    public void addEmployee(Employees employees){
        int insert = employeesMapper.insert(employees);
        System.out.println(insert);
    }
}
